# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Maxime Gauduin <alucryd@gmail.com>

_gemname=iconv
pkgname=ruby-$_gemname
pkgver=1.0.8
pkgrel=3
pkgdesc='Wrapper library for iconv'
arch=('loong64' 'x86_64')
url='https://github.com/ruby/iconv'
license=('BSD')
depends=('ruby')
options=('!emptydirs')
source=("https://rubygems.org/downloads/$_gemname-$pkgver.gem")
noextract=("$_gemname-$pkgver.gem")
b2sums=('f706a8baf5136e0b165190361a340d39f6fda8f65896559cbc3b4933e54930d9dcd2f06a9059040da002e06eb1f45a2918a8562d51a8d0853f3e4613aec0acc1')

package() {
  local _gemdir="$(ruby -e'puts Gem.default_dir')"

  gem install \
    --verbose \
    --ignore-dependencies \
    --no-document \
    --no-user-install \
    --install-dir "$pkgdir/$_gemdir" \
    --bindir "$pkgdir/usr/bin" \
    "$_gemname-$pkgver.gem"

  # delete unnecessary files & folders
  cd "$pkgdir/$_gemdir"
  rm -vrf cache
  rm -vrf "extensions/$CARCH-linux/$(basename $_gemdir)/$_gemname-$pkgver/"{gem_make.out,mkmf.log}
  cd "gems/$_gemname-$pkgver"
  find . -type f -name ".*" -delete
  rm -vrf Gemfile Rakefile "$_gemname.gemspec" ext test

  # move documentation
  install -vd "$pkgdir/usr/share/doc/$pkgname"
  mv -vt "$pkgdir/usr/share/doc/$pkgname" README.md

  # move license
  install -vd "$pkgdir/usr/share/licenses/$pkgname"
  mv -vt "$pkgdir/usr/share/licenses/$pkgname" BSDL LICENSE.txt
}
# vim: ts=2 sw=2 et:
